// page/component/setting/setting.js
Page({
    data: {
        // 页面数据：用户设置选项
        settings: {
            pushNotice: true, // 推送通知开关
            darkMode: false,  // 深色模式开关
            version: "1.0.0"  // 版本号
        }
    },

    onLoad: function() {
        // 页面加载时读取本地存储的设置
        const storedSettings = wx.getStorageSync('userSettings');
        if (storedSettings) {
            this.setData({ settings: storedSettings });
        }
    },

    // 切换推送通知开关
    togglePush: function(e) {
        const newSettings = { ...this.data.settings };
        newSettings.pushNotice = e.detail.value;
        this.setData({ settings: newSettings });
        wx.setStorageSync('userSettings', newSettings); // 保存到本地存储
    },

    // 切换深色模式开关
    toggleDarkMode: function(e) {
        const newSettings = { ...this.data.settings };
        newSettings.darkMode = e.detail.value;
        this.setData({ settings: newSettings });
        wx.setStorageSync('userSettings', newSettings);
        // 可添加深色模式切换逻辑
    },

    // 跳转关于页面
    goToAbout: function() {
        wx.navigateTo({
            url: '/page/component/about/about'
        });
    }
})